# -*- coding: utf-8 -*-
# Python 计算列表元素之积

# ddemo-1
def multiplyList(my_list):
    result = 1
    for x in my_list:
        result = result * x
    return result

list1 = [1, 2, 3]
list2 = [3, 2, 4]
print(multiplyList(list1))
print(multiplyList(list2))


# demo-2
from functools import reduce
list1 = [1, 2, 3]
sum = reduce(lambda x,y:x*y,list1)
print(sum)


# demo-3
def list_product(list_1,size):
    if size == 0:
        return 1
    else:
        return list_1[size-1] * list_product(list_1,size - 1)


list_1 = [i for i in range(3,6)] #生成列表[3,4,5]
print(list_1)
print(list_product(list_1,len(list_1)))